Prevention of deadlock in a distributed computing environment

ABSTRACT

A method for preventing deadlock in a distributed computing system includes the steps of: receiving as input a sorted set of containers defining a unique global sequence of containers for servicing process requests; populating at least one table based at least in part on off-line analysis of call graphs defining corresponding transactions for a given order of the containers in the sorted set; storing within each container at least a portion of the table; and allocating one or more threads in a given container according to at least a portion of the table stored within the given container.

CROSS-REFERENCE TO RELATED APPLICATION(S)

The present application is related to a commonly assigned U.S.application entitled “Prevention of Deadlock in a Distributed ComputingEnvironment,” identified by Ser. No. 11/945,712, and filed on even dateherewith, the disclosure of which is incorporated by reference herein inits entirety.

FIELD OF THE INVENTION

The present invention relates to the electrical, electronic, andcomputer arts, and, more particularly, to techniques for preventingdeadlock in a distributed computing environment.

BACKGROUND OF THE INVENTION

In a computing context, “deadlock” refers to a condition when two ormore processes are each waiting for a resource held by another process,or when more than two processes are waiting for resources in a circularchain. Generally, only a process holding a resource may release theresource, and typically a process will not release the resource untilprocessing has been completed.

Consider an enterprise service oriented architecture (SOA) environment,which can be seen as a set of web services deployed on middlewareassociated with a number of web service containers. One web serviceexposes a number of operations/methods and a method implementation mayinvoke one or more methods of other web services (often referred to as“nested calls”). A web service container typically hosts a number of webservices and provides various resources that are necessary to processthe requests made to the respective web service methods. Resourcesprovided by the container are shared among processing of differentrequests to web service methods. A processing thread, or simply a“thread,” is one such resource.

In prevalent design of web service containers, the web service containermaintains a pool of threads, often referred to as a “thread pool.” Whena request for a web service method arrives at the container, it picks anavailable thread in the thread pool and allocates the thread to processthe request. If there is no thread available in the thread pool, therequest is added to a waiting queue. The allocated thread is notreleased until the processing of the request has been completed. When athread is released back into the thread pool, it is allocated to arequest waiting in the queue, if any, based on a prescribed queuingpolicy (e.g., first-in first-out (FIFO)).

Typically, an upper bound is kept on the number of threads in the threadpool. This upper bound is established for various performance reasons,including, but not limited to, the significant cost of the overheadassociated with thread management. Due to the upper bound on the threadpool size, various scenarios in a distributed SOA environment can leadto distributed deadlock. These scenarios may include cases where nocycles are present at a service component layer. Consider the followingillustrative scenario:

-   -   two web services containers, C1 and C2, each having an upper        bound of one on the thread pool size.    -   Container C1 hosts two web services methods, M₁ and M₁₋₂.        Container C2 hosts two web services methods, M₂ and M₂₋₁.    -   Implementation of method M₁₋₂ invokes method M₂, and        implementation of method M₂₋₁ invokes method M₁.

Now consider a situation when container C1's thread and container C2'sthread are allocated to web service requests for methods M₁₋₂ and M₂₋₁,respectively. During the processing of these methods, M₁₋₂ invokesmethod M₂, and method M₂₋₁ invokes method M₁, but none of these nestedcalls can be processed since, in both containers, all threads (onethread each) are busy and thus no threads are available for allocationto these requests. Furthermore, the threads will not be released by theongoing requests processing methods M₁₋₂ and M₂₋₁ since completion oftheir respective processing is dependent on the completion of thesenested calls. Accordingly, a deadlock situation arises. Even when theupper bound on the size of the thread pool is greater than one, suchdeadlocks can occur due to concurrent transactions.

The deadlock problem is not new in distributed systems and has been asubject of interest from theoretical as well as practical perspectives.However, in enterprise component middleware, deadlock was not observedas frequently, since a tiered architecture was the most common style ofdeveloping applications. As SOA becomes more widespread as anarchitecture style for reusing business functions in the form of webservices and describing business processes in the form of compositeservices, there is a motivation to find efficient solutions for thedeadlock problem.

In distributed systems, three major strategies that are applicable tohandling deadlock are: deadlock prevention (e.g., designing offlineresource requesting protocols); deadlock detection and recovery, whichincludes development of algorithms for detecting deadlock in a systemand providing measures to bring the system back to a deadlock-freestate; and deadlock avoidance, which includes development of onlinecontrol policies that keep track of current resource allocation status,possibly combined with information about future process resourcerequirements, to keep the system away from deadlock states.

Conventional methodologies for deadlock detection and recovery generallyinvolve maintaining a wait-graph of requests and preempting processes(e.g., removing a resource from a process) when deadlock is detected,which is undesirable. With regard to deadlock avoidance, one classicdeadlock avoidance algorithm for non-distributed systems is thewell-known Dijkstra's Banker's algorithm. However, for distributedsystems, the general solution to distributed deadlock is impracticalsince it requires global atomic actions, or distributed synchronization.

Accordingly, there exists a need for deadlock prevention techniques thatdo not suffer from one or more of the limitations exhibited byconventional approaches.

SUMMARY OF THE INVENTION

Techniques of the present invention meet the above-noted need bypreventing deadlock in an enterprise SOA environment. The inventiontakes advantage of a call graph that is available in SOA applicationsand exploits the reusable property of threads for handling loops in thecall graph, thereby enhancing thread utilization efficiency. Embodimentsof the invention achieve deadlock prevention by a combination ofpartially preempting the threads and partially avoiding a circular waitcondition, a primary cause of deadlock. Moreover, resource preemption isbeneficially achieved without significantly degrading systemperformance.

In accordance with one embodiment of the invention, a method ofpreventing deadlock in a distributed computing system includes the stepsof: receiving as input a sorted set of containers defining a uniqueglobal sequence of containers for servicing process requests; populatingat least one table based at least in part on off-line analysis of callgraphs defining corresponding transactions for a given order of thecontainers in the sorted set; storing within each container at least aportion of the table; and allocating one or more threads in a givencontainer according to at least a portion of the table stored within thegiven container.

In accordance with a further embodiment of the invention, a system isprovided for preventing deadlock in a distributed computing system. Thesystem includes a memory and at least one processor coupled to thememory. The processor is operative: to receive as input a sorted set ofcontainers defining a unique global sequence of containers for servicingprocess requests; to populate at least one table based at least in parton off-line analysis of call graphs defining corresponding transactionsfor a given order of the containers in the sorted set; to store withineach container at least a portion of the at least one table; and toallocate one or more threads in a given container according to at leasta portion of the at least one table stored within the given container.

In accordance with yet a further embodiment of the invention, a computerprogram product is provided comprising a computer useable mediumincluding computer usable program code for preventing deadlock in adistributed computing system. The computer program product includes:computer usable program code for receiving as input a sorted set ofcontainers defining a unique global sequence of containers for servicingprocess requests; computer usable program code for populating at leastone table based at least in part on off-line analysis of call graphsdefining corresponding transactions for a given order of the containersin the sorted set; computer usable program code for storing within eachcontainer at least a portion of the at least one table; and computerusable program code for allocating one or more threads in a givencontainer according to at least a portion of the at least one tablestored within the given container.

These and other features, aspects, and advantages of the presentinvention will become apparent from the following detailed descriptionof illustrative embodiments thereof, which is to be read in connectionwith the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates an exemplary call graph which may be used inperforming at least a portion of a deadlock prevention methodology, inaccordance with an aspect of the invention;

FIG. 2 illustrates an exemplary placement of each of a plurality ofphases of call handling by a container, according to another aspect ofthe invention;

FIG. 3 is a process flow diagram depicting an exemplary method performedduring a pre-method execution phase of an ordered distributed containersthread allocation (ODCTA) methodology, in accordance with an aspect ofthe invention;

FIG. 4 is a process flow diagram depicting an exemplary method performedduring a post-method execution phase of the ODCTA methodology, inaccordance with an aspect of the invention; and

FIG. 5 depicts a computer system that may be useful in implementing oneor more aspects and/or elements of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

One or more embodiments of the invention provide techniques forpreventing deadlock in an enterprise SOA environment. While referencemay be made to specific illustrative algorithms and/or pseudo-code usedin describing certain aspects of the invention, it is to be appreciatedthat the invention is not limited to these specific algorithms and/orpseudo-code, and that one skilled in the art given the teachings hereinmay propose modifications thereto that are within the scope of thepresent invention.

The phenomenon of deadlock has been studied extensively in the contextof computer operating systems. For deadlock to occur among concurrenttransactions, four conditions must be present: mutual exclusion (i.e.,tasks claim exclusive control of the resources they require),hold-and-wait (i.e., tasks hold resources already allocated to themwhile waiting for additional resources), no preemption (i.e., resourcescannot be forcibly removed from the tasks holding them until theresources are used to completion), and circular wait (i.e., a circularchain of tasks exists, such that each task holds one or more resourcesthat are being requested by the next task in the chain). Theseconditions are sometimes referred to as Coffman conditions, from theirfirst description in the text by E. G. Coffman, et al., “SystemDeadlocks,” ACM Computing Surveys, Vol. 3, No. 2, pp. 67-78 (1971),which is incorporated by reference herein. All of these four conditionsmust be present for deadlock to occur and if one of these conditions isremoved, deadlock will not occur.

Techniques of the present invention achieve deadlock prevention byremoving one or more of the above-noted necessary conditions. Forexample, in accordance with an illustrative aspect of the invention,deadlock prevention is achieved by eliminating a circular waitcondition. In accordance with a further aspect of the invention, anon-preemption condition is selectively removed, for efficiency, incases where a transaction visits a particular container more than onceduring the course of execution of, for example, nested calls. Resourcepreemption can be achieved without significantly degrading systemperformance by exploiting a salient property of a specific resource,namely, a thread. The term “thread” as used herein is intended to referto an execution context, a resource necessary to run a computation. Athread can be preempted from a call and allocated to essentially anymulti-level nested call that arrives to the same container, without anyadverse effect on the enclosing call, since unless the nested call isprocessed, the enclosing call cannot proceed with its processing anyway.

Removing the no preemption condition can be accomplished by allocatingone thread per transaction per container at any given time. Each timethe transaction revisits the container during a given request, due tothe execution of a nested call, the same thread is used for executingthe request. For removing the circular wait condition, an on-demandthread reservation technique is preferably employed for selective callsin such a manner that for all transactions, threads are allocated indifferent containers, to distributed transactions, in a predeterminedorder of containers, which may be referred to herein as a globalcontainers sequence, irrespective of the order in which transactionsvisit the containers. Using this methodology, only some calls ofselective transactions may require thread reservation.

The illustrative deadlock prevention methodology according to anembodiment of the invention assumes knowledge of interactions among webservices hosted on containers. There are numerous techniques and toolsthat can be used to derive this knowledge, as will become apparent tothose skilled in the art given the teachings herein. By way of exampleonly and without limitation, static analysis techniques, as described,for example, in F. Xiang, F., et al., “Analysis of Interacting BPEL WebServices,” Proceedings of the 13th International Conference on WorldWide Web, pp. 621-630 (2004), and D. Grove, et al., “A Framework forCall Graph Construction Algorithms,” ACM Transactions on ProgrammingLanguages and Systems, Vol. 23, pp. 685-746 (2001), the disclosures ofwhich are incorporated by reference herein, run time monitoringtechniques (e.g., IBM Tivoli Composite Application Manager for SOA, andIBM Web Services Navigator), or a combination of static analysis and runtime monitoring techniques, can be used to derive knowledge regardingthe interaction among web services.

Embodiments of the invention perform an off-line analysis of call graphsof each of the web services methods and provide each container with someessential local information. A “call graph” (sometimes referred to as acall multigraph) is a directed graph that represents a callingrelationship among subroutines, or among other sub-processes, in acomputer program. The call graph includes certain information about theprogram's control flow and it can be at least partially determinedstatically. However, the call graph is typically a nondeterministicentity, since branch execution is decided at run time. At run time,containers use the local information provided by the call graphs foremploying the two techniques discussed above, preferably withoutconsulting any central point or each other. Moreover, no complexcomputation is required at run time in containers, as the localinformation is stored in the form of a map and only a few map operationsare performed that can be achieved in constant time.

A SOA enterprise environment can be modeled as a tuple (C, G) includinga set of web services containers C: {C₁, C₂ . . . C_(N)} and a set ofcall graphs G: {G₁, G₂ . . . G_(N)}, where G_(i) represents a call graphfor a web service method hosted on container C_(j). A call graph is afinite tree including a plurality of execution nodes. An execution nodecan be represented as a tuple (M, C), where M is a web service methodthat executes in container C. A uniquely labeled edge from (M_(x),C_(x)) to (M_(y), C_(y)) denotes that method M_(x), while executing incontainer C_(x), invokes method M_(y) in container C_(y) synchronously,where x and y are two different integers. Call graphs are modeled forthose web service methods whose call can be originated from an entityoutside the set of containers, such as, for instance, an external webservice client. A “transaction” can be defined herein as a runninginstance of a call graph corresponding to a web service method. A“transaction type” may be defined herein as a unique identifier for acall graph. An edge container, in the context of a transaction, is thecontainer C corresponding to root node (M, C) of a call graph of thetransaction. A “flow” may be defined as a path from a root node to aleaf node in the call graph.

In a call graph, “OR nodes” can be introduced to handle mutualexclusion. OR nodes are preferably defined herein as having more thanone child node. Only one of the child nodes of an OR-node will beexecuted for a given transaction, based on a condition determined at runtime. Likewise, “AND nodes” can be introduced to handle parallelism. ANDnodes are preferably defined herein having more than one child node. Allthe child nodes of an AND node will be executed concurrently. An edgefrom an execution node (M, C) to an AND/OR node preferably denotes thatmethod M, in the course of execution, invokes methods indicated by theexecution node children of the AND/OR nodes. OR nodes in the call graphrepresent the scenario of choosing one of the competing services; ANDnodes in the call graph represent the scenario of parallel processing.Both scenarios, namely, choosing one of the competing services andparallel processing, are frequently observed in composite services in aSOA enterprise environment.

Leaf nodes and a root node in the call graph are preferably always ofkind execution nodes. An execution node can have children of any nodetype while AND/OR nodes cannot have children of their own type. Theorder of execution of children nodes of an execution node may berepresented as a left-to-right order of children nodes.

Tuple (M_(z), C_(w)) may be used to represent a nested call of (M_(x),C_(y)) when (M_(x), C_(y)) is an ancestor of (M_(z), C_(w)) in a callgraph. There may be said to be a loop at node (M_(x), C_(y)) when thenode has a nested call (M_(z), C_(w)), such that C_(y)=C_(w).

Attention should now be given to FIG. 1, which shows an exemplary callgraph 100 which may be used in performing at least a portion of adeadlock prevention methodology, in accordance with an aspect of theinvention. As apparent from call graph 100, container C1 hosts methodsM1 and M5, container C2 hosts methods M2, M3, M4 and M6, and containerC3 hosts methods M3 and M7. Method M1 first invokes method M2 incontainer C2 and receives a reply from M2. Then, method M1 invokesmethod M3 in container C3 and, after receiving a reply from M3, invokesmethod M4 in container C2. During execution of method M4, either methodM5 is invoked in container C1, or method M3 is invoked in container C2via OR node 102. During execution, method M5 concurrently invokesmethods M6 and method M7 via AND node 104. In call graph 100, a call tomethod M5 is essentially a nested call of methods M4 and M1, and thereare some loops present, such as, for example, along a path representedby (M1, C1)→(M4, C2)→(OR)→(M5, C1). Call graphs similar to call graph100 may be observed, for instance, in a composite SOA environment, wherea web service is implemented using Business Process Execution Language(BPEL) including fork, join and/or branching constructs.

An illustrative model defining a process of handling a call for a methodby a hosting container will now be described. The process of handling acall is preferably categorized into a plurality of phases, including apre-method execution phase, a method execution phase, a pre-invoke outphase, a post-invoke out phase, and a post-method execution phase. It isto be understood, however, that the invention is not limited to thespecific number and/or type of phases described herein.

FIG. 2 illustrates an exemplary placement of each of theabove-identified phases of call handling by a container, in accordancewith an aspect of the invention. The pre-method execution phase 202 andpost-method execution phase 210 represent processing wherein thecontainer allocates and de-allocates, respectively, a thread forexecuting a given web service method. The method execution phase 204represents the processing of actual implementation code corresponding tothe web service. During the method execution phase, methodimplementation may invoke other web services. The pre-invoke out phase206 and post-invoke out phase 208 correspond to invocation of anotherweb service and getting a corresponding reply, respectively, from withinthe web service implementation code.

In all the phases except the method execution phase, the container codeis executed; during the method execution phase, the control of thethread resides with the implementation code of the web service. Transferof control between container code and web service implementation code isachieved via standardized application programming interface (API)invocations.

Ordered Distributed Containers Thread Allocation Methodology

An exemplary methodology, referred to herein as an ordered distributedcontainers thread allocation (ODCTA) methodology, will now be describedaccording to one embodiment of the invention. First, an illustrativecase for handling a simple call graph that does not contain any AND/ORnodes will be considered. This simple case can then be extended, inaccordance with other aspects of the invention, to handle more complexcall graphs which incorporate AND/OR nodes as well, using the teachingsset forth herein. It is to be understood that the ODCTA methodology ismerely illustrative, and that other techniques for achieving theadvantages and objectives of the invention are similarly contemplated.

In the exemplary ODCTA methodology, each container maintains threetables, namely, an allocation table, a reservation table and acommanding table. The following definitions will be used in connectionwith these tables:

Allocation table {transaction id, thread id}: An example entry [txid,thid] into this table means that a thread with id thid is allocated to atransaction with id txid.

Reservation table {transaction id, thread id, reservation counter}: Anexample entry [txid, thid, num] into this table means that a thread withid thid is reserved for a transaction with transaction id txid, withvalue of reservation counter as num.

Commanding table {transaction type, E, CR}: An example entry [tx-type,E1, CR={(C₁, 1), (C₂, 2)}] into this table at container C means thatbefore allocating a thread to a transaction of type tx-type, when thetransaction visits the container following edge E in the call graph oftransaction type tx-type, C requests container C, and container C₂ toreserve a thread for the transaction. The reservation count is 1 forcontainer C₁ and 2 for container C₂, in this example.

The entries in the allocation table and the reservation table preferablykeep updating at run time, while entries in the commanding table arepopulated statically by off-line analysis of all distinct call graphs.

In accordance with the exemplary ODCTA methodology, when a requestarrives for execution of a method M of web-service hosted on a containerC, the following steps are initiated:

Pre-Method Execution Phase

FIG. 3 is a process flow diagram depicting an exemplary method 300performed during a pre-method execution phase of the ODCTA methodology,in accordance with an aspect of the invention. Method 300 will bedescribed in further detail below with reference to FIG. 3. During thepre-method execution phase, upon receiving a request in block 302:

(a) In block 304, the container C checks for a transaction id and edgeid associated with the request. When there is no such identifier,process flow proceeds to block 306, where the container assumes itselfto be an edge container for the transaction and generates a globallyunique transaction id. The container then associates the uniquetransaction id and a transaction type with the request in block 308.

(b) The container, whether an edge container or otherwise, then checkswhether a thread has already been allocated or reserved for thistransaction id. The container may determine this by looking for atransaction id entry in the allocation table and the reservation table,respectively. Block 310 checks to see whether a thread has beenallocated, and if not, block 312 checks to see whether a thread has beenreserved.

-   -   i. When block 310 determines that a thread has already been        allocated, the container C exits the pre-method execution phase        and uses the allocated thread to execute the method M in block        322. An objective of this step is to reuse the thread in the        case of a loop in the transaction by preempting the thread from        an enclosing call and allocating it to a nested call. This does        not affect the overall performance because the response to the        enclosing call that the thread waits for would not arrive at the        container until the nested call is processed completely, due to        a new call being a nested call in the same transaction from the        perspective of an earlier call. This mechanism ensures that the        container does not allocate more than one thread for the same        transaction at any given point in time.    -   ii. When a thread has not already been allocated but block 312        determines that there is a reserved thread for the transaction,        the container C allocates the reserved thread to the request in        block 314.    -   iii. When there is neither an already allocated thread nor a        reserved thread for the transaction, process flow continues to        block 316, where the container C first sends a thread        reservation request to one or more other selected containers        that appear in a prescribed (e.g., pre-computed) ordered set CR;        container C obtains CR by looking into the commanding table for        an entry for the transaction type associated with the        transaction. These thread reservation requests are sent one        after another in the order of appearance of the containers in        ordered set CR. For example, a request to container C₂ is sent        after a reply from container C₁ arrives, if C₁ precedes C₂ in        the ordered set CR.

The commanding table in each container may be populated by offlinecomputation, such as, for example, by an out-of-order reservation (OoOR)algorithm, which will be described in further detail herein below.Alternative methodologies for populating the commanding table may alsobe employed, as will become apparent to those skilled in the art giventhe teachings herein. One objective of the OoOR algorithm is to performan analysis of all distinct call graphs and populate the maps insubstantially all the containers such that the order of containersallocating the thread, for any transaction, is always a sub-sequence ofa prescribed order of containers (e.g., global containers sequence). Athread reservation request preferably comprises two parameters: atransaction id; and an integer reservation counter. On receiving athread reservation request, each container in the ordered set CRreserves a thread for the transaction and puts a corresponding entryinto its reservation table and then sends a thread reservation replyback to container C.

(c) After container C receives thread reservation replies from therespective containers present in the ordered set CR, the container, inblock 318, allocates a thread for execution of method M by following themechanism existing in prevalent designs of containers described hereinabove. The container C also adds a corresponding entry into itsallocation table indicating that the thread has been allocated in block320 before exiting the pre-method execution phase and executing themethod M in block 322.

Pre-Invoke Out Phase

During the pre-invoke out phase, the container C associates atransaction id, a transaction type, and an edge id with the web servicerequest that it goes out to, as a consequence of invoking the nestedcall.

Post-Method Execution Phase

FIG. 4 is a process flow diagram depicting an exemplary method 400performed during a post-method execution phase of the ODCTA methodology,in accordance with an aspect of the invention. Method 400 will bedescribed in further detail below with reference to FIG. 4. During thepost-method execution phase, after completion of method M execution inblock 402:

(a) if the thread is automatically released back to the thread pool, asdetermined in block 404, the corresponding entry from the allocationtable is removed in block 406. This might happen, for example, when thecompleting method is the one to which the thread was allocated from thethread pool, not by preempting from an enclosing request. If, afterexecution of method M, the thread is not released back to the threadpool, method 400 exits at block 418.

(b) if the entry in the allocation table is removed in block 406, thecontainer C, in block 408, determines whether there is a correspondingentry for the transaction in the reservation table. When there is anentry for the transaction in the reservation table, the value of thereservation counter is decremented in block 410, preferably by one,although alternative counting schemes are contemplated. When there is noentry in the reservation table for the transaction, method 400 exits atblock 418. The value of the reservation counter is then checked in block412.

(c) when, in block 412, it is determined that the value of thereservation counter corresponding to the entry for the transaction inthe reservation table becomes zero, the entry is removed from thereservation table in block 414 and the thread is returned back to thethread pool in block 416, after which the post-method execution phase isexited in block 418. When the reservation counter is not equal to zero,as determined in block 412, method 400 exits at block 418.

Using the illustrative ODCTA methodology described above, deadlockprevention is achieved. As proof of this, consider the following. InODCTA, thread reservation requests are sent by a participating containerin such a way that for each transaction, the thread allocation follows aglobal container sequence. Since the global container sequence is uniqueby definition, for all transactions, no cyclic dependencies arise.Hence, ODCTA achieves deadlock freedom.

OoOR Algorithm

In conjunction with an implementation of the ODCTA methodology, thecommanding tables of each of the containers can be populated by offlinecomputation, as previously stated. An exemplary methodology forpopulating the respective commanding tables using OoOR will now bedescribed for a given global container sequence, according to a furtheraspect of the invention. The methodology is preferably applied to allthe call graphs independently. It is to be appreciated that alternativemethodologies for populating the commanding tables may also be employed,in accordance with other embodiments of the invention.

Given a call graph G and a corresponding global container sequence S,the methodology computes set CR(C) for an entry {tx-type, CR(C)} in acommanding table of container C, where tx-type is the transaction typefor call graph G. An ordering relation “>” is defined between containersC₁ and C₂, such that C₁>C₂, if C₁ comes before C₂ in the globalcontainer sequence. An ordering relation “>” is also defined betweennodes (M₁, C₁) and (M₂, C₂) in a call graph, such that (M₁, C₁)>(M₂, C₂)if (M₁, C₁) is an ancestor of (M₂, C₂) in the call graph (i.e., a callto method M₂ is a nested call from method M₁).

First, all flows (F₁, F₂ . . . F_(n)) present in the call graph arecomputed. For every node (M, C) in flow F_(i) (where i is an integer), aset OoO((M, C), F_(i)) is computed. This set preferably contains onlythose nodes (M_(x), C_(x)) of the flow F_(i) such that, for (M,C)>(M_(x), C_(x)) and C_(x)>C, the set OoO((M, C), F_(i)) can becomputed according to the expression:OoO((M,C),F _(i))={(M _(x) ,C _(x))|(M _(x) ,C _(x))εF _(i),(M,C)>(M_(x) ,C _(x)),C _(x) >C}.The significance of set OoO((M, C), F_(i)) is that it includes all nodes(M_(x), C_(x)) such that a thread is allocated at container C_(x) beforea thread allocated at container C. The order of containers allocatingthe thread to the flow is therefore always a subsequence of the globalcontainer sequence.

Next, for every node (M, C) in flow F_(i), set RT((M, C), F_(i)) iscomputed. This set includes the containers to whom container C will sendthread reservation requests before allocating a thread to the flow. Forcomputing set RT((M, C), F_(i)), nodes of flow F_(i) are traversed fromroot node to leaf node. As the nodes of flow F_(i) are traversed, thecontainers to which the thread reservation requests are to be sent arekept track of (e.g., recorded) in a temporary set, TempRes(F_(i)). Foreach new node (M, C) visited, the set RT((M, C), F_(i)) is preferablycomputed as including only those containers of set OoO((M, C), F_(i))for which a thread reservation request will not be sent. This may berepresented by the expression:RT((M,C),F _(i))={C _(x)|(M _(x) ,C _(x))εOoO((M,C),F _(i))}−TempRes(F_(i)).

The temporary set TempRes(F_(i)) is updated by adding new RT((M, C), Fi)and C to TempRes(F_(i)). This is done primarily because if an ancestornode in the flow has decided to send the thread reservation request to aparticular container, the descendent node need not also send the threadreservation request. Exemplary pseudo-code for computing all values ofthe set RT((M, C), F_(i)) is shown below, in accordance with anembodiment of the invention.

algorithm OoO  For every node (M, C) and flow F_(i), compute OoO((M, C),F_(i))  For flow f in F₁, F₂ . . . F_(x)   TempRes = ∅    For node (M,C) in (M₁, C₁), (M₂, C₂), . . . (M_(y), C_(y)) of flow f     RT((M,C),f) ← { C_(x) |( M_(x), C_(x)) ∈ OoO((M, C),f)} − TempRes     TempRes← TempRes ∪ RT((M, C),f)   end − For  end − For end algorithm

The computation of the set CR(C) from all values of RT((M, C), F_(i)) isrelatively straight forward. In an illustrative embodiment, set CR(C)can be computed as follows:

1. If an incoming edge to node (M, C) belongs to only one flow F_(i),set CR(C) is populated by the containers belonging to set RT((M, C),F_(i)). The thread reservation count in this illustrative case is onefor each container entry. The ordering of containers in set CR(C) ispreferably configured to follow the ordering of the global containersequence.

2. If an incoming edge to node (M, C) belongs to more than one flow, setCR(C) is populated by combining all containers belonging to set RT((M,C), F_(i)) of all such flows. In this aggregated set, each occurrence ofthat container C_(x) is replaced by adding entry (C_(x), # occurrence)to set CR(C). Once again, the ordering of containers in set CR(C) isconfigured to follow the ordering of the global container sequence.

Extension of the ODCTA Methodology for Handling Complex Transactions

As will be described herein below, the ODCTA methodology can be utilizedto handle complex transactions (e.g., transactions whose correspondingcall graphs include AND nodes and/or OR nodes), in accordance with afurther aspect of the invention. By way of example only, first, duringoff-line processing of a call graph corresponding to a giventransaction, all AND nodes are preferably removed, one by one, in adepth-first manner. More particularly, in removing an AND node, one ofthe sub-trees in the call graph is moved to the parent node while therest of the sub-trees are treated as distinct call graphs. If a rootnode of a separated sub-tree is an OR node, the OR node is removed andall sub-trees associated therewith are treated as distinct call graphs.The rational for treating all but one of the sub-trees of an AND node asa distinct call graph is that in containers an extra thread per parallelbranch is allocated for handling a concurrency. Moreover, all descendentexecution nodes require a separate thread in their hosting container inorder to maintain the concurrency.

After removing the AND nodes in the call graph, only distinct callgraphs remain, each distinct call graph including execution nodes and/orOR nodes. By introducing one more tables that each container Cmaintains, namely, a release commanding table, the ODCTA methodology canbe extended to handle OR nodes. Each entry in the release commandingtable is preferably of the type {tx-type, E1, C₂}, where in thepost-invoke out phase for a transaction of type tx-type for an out-goingcall corresponding to edge E1, container C sends a thread releaserequest to container C₂. Upon receiving a thread release request for atransaction type, container C₂ decreases the reservation counter by onein the reservation table. The rational behind this is that as soon as itis known at run time which one out of multiple child nodes of an OR nodeis to be invoked, the threads that were reserved for other paths can bereleased. The entries for the release commanding table are populated atthe time of off-line analysis. One exemplary methodology for populatingentries in the release commanding table is shown below in pseudo-code,in accordance with an illustrative embodiment of the invention. Theexemplary methodology uses ordered set CR for a node (M, C) in the callgraph described above.

algorithm ReleaseCommandingTable Population  For each C_(i) in CRassociated with node (M, C)   For each (X, C_(i)) node, where (X, C_(i))is descendent of (M, C), and not   descendent of any (Y, C_(i)) node   For each OR node ON in path P from node (X, C_(i)) to node (M, C)    For each outgoing edge E of ON, such that E is not in P      Addentry {tx-type, E, C_(i)} into release commanding table of      Cend-algorithm

As previously stated, salient tasks of the ODCTA methodology can beimplemented in a SOA environment. One such task is the generation ofvarious identifiers at the time of off-line analysis for populating thecommanding and release commanding tables. By way of example only, thedesignation M.C can be used as a unique identifier for a transactiontype of a call graph, where (M, C) is a root node of the call graph. Forassigning a unique identifier to an edge inward to node (M, C) in thecall graph, we traverse a path from the root node to the node (M, C) andcompute the identifier by concatenating method names of nodes visitedalong the path, separated by “.”.

At run time, the propagation of identifiers with a transaction can beachieved by adding a special purpose simple object access protocol(SOAP) header to outgoing web services request messages. The edgecontainer preferably associates an appropriate transaction type, anempty edge id, and a unique transaction id (e.g., globally unique randomnumber) with the incoming request, in the pre-method processing phase.All containers, including the edge container, pass the identifiersassociated with the incoming request (e.g., transaction id, transactiontype, and edge id), along with the service request for the nested callsgoing out to a node (M, C) in the pre-invoke out phase, although theedge id is modified by appending .M in the process. All containers usethe transaction id, transaction type, and edge id associated with anincoming request for making thread allocation decisions in accordancewith the illustrative ODCTA methodology described above.

Data structures may be used for maintaining the local information ateach container and operations for using and updating the datastructures, as discussed in connection with the ODCTA methodology, willbecome to those skilled in the art given the teachings herein.Consequently, operations for updating the data structures will not bepresented in further detail herein. Moreover, techniques of the presentinvention described herein may be implemented across heterogeneouscontainer implementations.

From a thread utilization perspective, in accordance with anillustrative embodiment of the invention, a thread is reserved only whenthe global container sequence has been violated. From a communicationcost perspective, there is a considerable cost associated with sending athread reservation message and receiving a reply. Accordingly, theglobal container sequence is an important parameter of the ODCTAmethodology. Preferably, the global container sequence is selected suchthat for most frequent transactions, the number of thread reservationrequests is relatively small. In this manner, communication costsassociated with sending and receiving thread reservation requests can besignificantly minimized while maintaining efficient thread utilization.

Exemplary System and Article of Manufacture Details

A variety of techniques, utilizing dedicated hardware, general purposeprocessors, firmware, software, or a combination of the foregoing may beemployed to implement the present invention or components thereof. Oneor more embodiments of the invention, or elements thereof, can beimplemented in the form of a computer product including a computerusable medium with computer usable program code for performing themethod steps indicated. Furthermore, one or more embodiments of theinvention, or elements thereof, can be implemented in the form of anapparatus including a memory and at least one processor that is coupledto the memory and operative to perform exemplary method steps.

One or more embodiments can make use of software running on a generalpurpose computer or workstation. With reference to FIG. 5, such animplementation might employ, for example, a processor 502, a memory 504,and an input/output (I/O) interface 506 formed, for example, by adisplay and a keyboard (not explicitly shown). The term “processor” asused herein is intended to include any processing device, such as, forexample, one that includes a CPU (central processing unit) and/or otherforms of processing circuitry. Further, the term “processor” may referto more than one individual processor. The term “memory” is intended toinclude memory associated with a processor or CPU, such as, for example,RAM (random access memory), ROM (read only memory), a fixed memorydevice (for example, hard drive), a removable memory device (forexample, diskette), a flash memory and the like. In addition, the phrase“input/output interface” as used herein, is intended to include, forexample, one or more mechanisms for inputting data to the processingunit (for example, mouse), and one or more mechanisms for providingresults associated with the processing unit (for example, printer). Theprocessor 502, memory 504, and I/O interface 506 can be interconnected,for example, via bus 508 as part of a data processing unit 500. Suitableinterconnections, for example via bus 508, can also be provided to anetwork interface (not explicitly shown), such as a network card, whichcan be provided to interface with a computer network, and to a mediainterface, such as a diskette or CD-ROM drive, which can be provided tointerface with media.

Accordingly, computer software including instructions or code forperforming the methodologies of the invention, as described herein, maybe stored in one or more of the associated memory devices (for example,ROM, fixed or removable memory) and, when ready to be utilized, loadedin part or in whole (for example, into RAM) and executed by a CPU. Suchsoftware could include, but is not limited to, firmware, residentsoftware, microcode, and the like.

Furthermore, the invention can take the form of a computer programproduct accessible from a computer-usable or computer-readable mediumproviding program code for use by or in connection with a computer orany instruction execution system. For the purposes of this description,a computer usable or computer readable medium can be any apparatus foruse by or in connection with the instruction execution system,apparatus, or device.

The medium can be an electronic, magnetic, optical, electromagnetic,infrared, or semiconductor system (or apparatus or device) or apropagation medium. Examples of a computer-readable medium include asemiconductor or solid-state memory (for example memory 504), magnetictape, a removable computer diskette, a random access memory (RAM), aread-only memory (ROM), a rigid magnetic disk and an optical disk.Current examples of optical disks include compact disk-read only memory(CD-ROM), compact disk-read/write (CD-R/W) and DVD.

A system, preferably a data processing system, suitable for storingand/or executing program code will include at least one processor 502coupled directly or indirectly to memory elements 504 through a systembus 508. The memory elements can include local memory employed duringactual execution of the program code, bulk storage, and cache memorieswhich provide temporary storage of at least some program code in orderto reduce the number of times code must be retrieved from bulk storageduring execution.

Input/output or I/O devices (including but not limited to keyboards,displays, pointing devices, and the like) can be coupled to the systemeither directly (such as via bus 508) or through intervening I/Ocontrollers (omitted for clarity).

Network adapters such as network interface (not explicitly shown) mayalso be coupled to the system to enable the data processing system tobecome coupled to other data processing systems or remote printers orstorage devices through intervening private or public networks. Modems,cable modem and Ethernet cards are just a few of the currently availabletypes of network adapters.

In any case, it should be understood that the components illustratedherein may be implemented in various forms of hardware, software, orcombinations thereof, for example, application specific integratedcircuit(s) (ASICS), functional circuitry, one or more appropriatelyprogrammed general purpose digital computers with associated memory, andthe like. Given the teachings of the invention provided herein, one ofordinary skill in the related art will be able to contemplate otherimplementations of the components of the invention.

It will be appreciated and should be understood that the exemplaryembodiments of the invention described above can be implemented in anumber of different fashions. Given the teachings of the inventionprovided herein, one of ordinary skill in the related art will be ableto contemplate other implementations of the invention. Indeed, althoughillustrative embodiments of the present invention have been describedherein with reference to the accompanying drawings, it is to beunderstood that the invention is not limited to those preciseembodiments, and that various other changes and modifications may bemade by one skilled in the art without departing from the scope orspirit of the invention.

1. A method of preventing deadlock in a distributed computing system,the method comprising the steps of: receiving as input a sorted set ofcontainers defining a unique global sequence of containers for servicingprocess requests; populating at least one table based at least in parton off-line analysis of call graphs defining corresponding transactionsfor a given order of the containers in the sorted set, the at least onetable comprising local information such that at run time each containeruses the local information, without accessing a central point in thesystem and without accessing another container, for making decisionsrelated to at least one of preemption, reservation, allocation andde-allocation of resources used for servicing the process requests;storing within each container at least a portion of the at least onetable; allocating one or more threads in a given container according toat least a portion of the at least one table stored within the givencontainer, the step of allocating one or more threads in a givencontainer further comprising the steps of: upon receiving a processrequest corresponding to a transaction, determining whether a uniqueidentifier has been assigned to the request; when a unique identifierhas not been assigned to the request, generating a unique identifier andassigning the identifier and a transaction type to the request;determining whether a thread is allocated for the transactioncorresponding to the identifier; when a thread has not been allocatedfor the transaction, determining whether a thread is reserved for thetransaction corresponding to the identifier; when a thread is notreserved for the transaction, sending a thread reservation request to atleast one selected container in the sorted set of containers andallocating a thread to the process request based at least in part on atleast one reservation reply from the at least one selected container;when a thread is reserved for the transaction, allocating the reservedthread to the process request; and adding an entry to an allocationtable corresponding to the at least one selected container, the entryindicating that a thread has been allocated to the transactioncorresponding to the identifier; after processing a method correspondingto a transaction associated with the given container, determiningwhether a thread used to process the method corresponding to thetransaction has been released back to a thread pool maintained by thecontainer; when the thread has been released back to the thread pool,removing an entry from an allocation table associated with thecontainer, the entry corresponding to the transaction; determiningwhether there is a corresponding entry for the transaction in areservation table associated with the container; when there is acorresponding entry for the transaction in the reservation table,decrementing a counter, the counter being used to track a number ofentries corresponding to the transaction in the reservation table; andwhen the counter has a value of zero, removing the entry correspondingto the transaction in the reservation table and returning the thread tothe thread pool; wherein the off-line analysis of call graphs comprises:for a given call graph and a corresponding global container sequence,computing an ordered set CR(C) for an entry {tx-type, CR(C)} in acommanding table of a container C, where tx-type is a transaction typefor the given call graph; defining an ordering relation “>” between twocontainers C₁ and C₂, such that C₁> C₂ when C₁ comes before C₂ in theglobal container sequence; defining an ordering relation “>” between twonodes (M₁, C₁) and (M₂, C₂) in the given call graph, such that (M₁,C₁)>(M₂, C₂) when (M₁, C₁) is an ancestor of (M₂, C₂) in the given callgraph; computing all flows (F₁, F₂, . . . , F_(n)) present in the callgraph, where n is an integer; computing a set OoO((M, C), F_(i)) forevery node (M, C) in flow F_(i) according to an expression OoO((M, C),F_(i))={(M_(x), C_(x))|(M_(x), C_(x))

F_(i), (M, C)>(M_(x), C_(x)), C_(x)>C}, where i is an integer, the setOoO((M, C), F_(i)) including nodes (M_(x), C_(x)) of the flow F_(i) suchthat (M, C)> (M_(x), C_(x)) and C_(x)>C; and computing a set RT((M, C),F_(i)) including containers to whom container C will send threadreservation requests before allocating a thread to the flow.